<?php
$vencedores = $this->vencedores;
?>

<p>
<div align="center" id="conteudoSemSidebar">
    <?php echo $this->dados; ?>
    <table width="75%" border="1" cellpadding="2" cellspacing="2">
        <tr>
            <td colspan="5" align="center"><h1><?php echo $this->nomebolao; ?></h1></td>
        </tr>
        <tr align="center" class="par">
            <td>Data do Jogo</td>
            <td>Campeonato</td>
            <td>Time A</td>
            <td>Time B</td>
            <td>Criador</td>
        </tr>
        <tr align="center">
            <td><?php echo $this->data; ?></td>
            <td><?php echo $this->campeonato; ?></td>
            <td><?php echo $this->time_a; ?></td>
            <td><?php echo $this->time_b; ?></td>
            <td><?php echo $this->criador; ?></td>
        </tr>
        <tr><td colspan="5">&nbsp;</td></tr>
        <tr class="par" align="center">
            <td>Apostas</td>
            <td>Bolitos</td>
            <?php if($this->apostou == true): ?>
            <td>Meu Palpite</td>
            <?php endif;?>
            <td colspan="3">&nbsp;</td>
            <!--td></td>
            <td></td-->
        </tr>
        <tr align="center">
            <td><?php echo $this->nro_apostas; ?></td>
            <td><?php echo ($this->nro_apostas)*5; ?></td>
            <?php if($this->apostou == true): ?>
            <td><?php echo $this->palpite; ?></td>
            <?php endif;?>
            <td colspan="3">&nbsp;</td>
            <!--td></td>
            <td></td-->
        </tr>
        <tr><td colspan="5">&nbsp;</td></tr>
        <tr align="center">
            <td colspan="3">&nbsp;</td>
            <td>Status:</td>
            <td><?php if($this->passou == true) echo 'Encerrado';
                    else echo 'Aberto'; ?></td>
        </tr>
        <tr align="center">
            <td colspan="3">&nbsp;</td>
            <td>&nbsp;</td>
            <td><?php
            if($this->apostou == false){
                $texto = 'Apostar';
                $controle = 'aposta';
                $acao = 'criar';
            } else {
                $texto = 'Editar Aposta';
                $controle = 'aposta';
                $acao = 'editar';
            }
            if($this->passou == true){
                echo '<s>Apostar</s>';
            } else {
                echo '<a href="'.$this->url(
                    array(
                        'controller'    => $controle,
                        'action'        => $acao,
                        'id_bolao'      => $this->id_bolao,
                    )
            ).'">'.$texto; } ?></a></td>
        </tr>
    </table>
    <?php if($this->passou == true) echo '<hr>
    <table width="75%" border="1" cellpadding="2" cellspacing="2">
        <tr>
            <td colspan="5" align="center"><h3>Resultado</h3></td>
        </tr>
        <tr align="center">
            <td width="20%">'.$this->time_a.'</td>
            <td width="20%">'.$this->gols_a.'</td>
            <td width="20%">X</td>
            <td width="20%">'.$this->gols_b.'</td>
            <td width="20%">'.$this->time_b.'</td>
        </tr>
    </table>'; ?>

<?php if ($vencedores != null): ?>
    <h1>Vencedores</h1>
                <table>
		<tr>
                    <th>Email</th>
                    <th>Bolitos</th>
		</tr>
		<?php
                      $par = true;
                      foreach($vencedores as $apostador): ?>
                          <?php if ($par) {
                                      echo "<tr class=\"par\">";
                                        $par = false;
                                    }
                                    else {
                                        echo "<tr>";
                                        $par = true;
                                    }
                                ?>
                                <td><?php echo $apostador[0]; ?></td>
                                <td><?php echo $apostador[1]; ?></td>

                         </tr>
                            <?php
                        endforeach; ?>
		</table>
	<?php endif; ?>
</div><br />
</p>